<template>
    <div>
        <p></p>
        <Button type="primary" @click="getInfo">获取数据</Button>
        <Table :columns="columns" :data="dataList"></Table>
    </div>
</template>

<script>
import dbModel from '../util/datastore'

let infoDb = dbModel.create('info')
export default {
    name: 'Index',
    data: function () {
        return {
            columns: [
                {
                    title: 'name',
                    key: 'name'
                },
                {
                    title: 'ip',
                    key: 'ip'
                },
                {
                    title: 'device',
                    key: 'device'
                },
                {
                    title: '操作',
                    key: 'action',
                    width: 300,
                    align: 'center',
                    render: (h, params) => {
                        return h('div', [
                            h('Button', {
                                props: {
                                    type: 'primary',
                                    size: 'small'
                                },
                                style: {
                                    marginRight: '5px'
                                },
                                on: {
                                    click: () => {
                                        this.editInfo(params.index)
                                    }
                                }
                            }, '修改'),
                            h('Button', {
                                props: {
                                    type: 'primary',
                                    size: 'small'
                                },
                                style: {
                                    marginRight: '5px'
                                },
                                on: {
                                    click: () => {
                                        this.show(params.index)
                                    }
                                }
                            }, '连接'),
                            h('Button', {
                                props: {
                                    type: 'error',
                                    size: 'small'
                                },
                                style: {
                                    marginRight: '5px'
                                },
                                on: {
                                    click: () => {
                                        this.remove(params.index)
                                    }
                                }
                            }, '添加图片'),
                            h('Button', {
                                props: {
                                    type: 'primary',
                                    size: 'small'
                                },
                                on: {
                                    click: () => {
                                        this.addFile(params.index)
                                    }
                                }
                            }, '操作')
                        ])
                    }
                }
            ],
            dataList: []
        }
    },
    methods: {
        getInfo: function () {
            let that = this
            infoDb.find({}, function (err, cet) {
                console.log(err)
                console.log(cet)
                that.dataList = cet
            })
        },
        editInfo () {

        },
        show () {

        },
        remove () {

        },
        addFile (id) {

        }
    }
}
</script>

<style scoped>

</style>
